let dayjs = require('dayjs')

// 生成随机流水号
const generateRandomSerialNumber = (data) => {
  const characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789'
  let serialNumber = ''

  for (let i = 0; i < 26; i++) {
    const randomIndex = Math.floor(Math.random() * characters.length)
    serialNumber += characters[randomIndex]
  }

  return {
    time: dayjs().format('YYYY-MM-DD HH:mm:ss'),
    serialNumber,
    data,
  }
}

module.exports = { generateRandomSerialNumber }
